﻿/* ######################################## *\
 * ### Copyright (C) 2009 AJ Ravindiran ### *
\* ######################################## */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AJRavindiran.Jolt.RuneScape.Models.Items
{
    /// <summary>
    /// Represents a single item.
    /// </summary>
    public class Item
    {
        #region Fields
        private int id;
        private int amount;
        #endregion Fields

        #region Properties
        /// <summary>
        /// The id of the item.
        /// </summary>
        public int Id
        {
            get { return this.id; }
        }

        /// <summary>
        /// The ammount of this item.
        /// </summary>
        public int Amount
        {
            get { return this.amount; }
        }
        #endregion Properties

        #region Constructors
        /// <summary>
        /// Constructs a new item.
        /// </summary>
        /// <param name="id">The item's client id.</param>
        public Item(int id)
        {
            this.id = id;
            this.amount = 1;
        }

        /// <summary>
        /// Constructs a new item.
        /// </summary>
        /// <param name="id">The item's client id.</param>
        /// <param name="ammount">The ammount of this item.</param>
        public Item(int id, int amount)
        {
            this.id = id;
            this.amount = amount;

            if (this.amount <= 0)
                this.amount = 1;
        }
        #endregion Constructors

        #region Methods
        /// <summary>
        /// Get accessor for the item's definitions.
        /// </summary>
        public ItemDefinition GetDefinition()
        {
            return RuneScape.GetItemManager().GetItemDefinition(id);
        }

        /// <summary>
        /// Duplicate the item.
        /// </summary>
        /// <returns></returns>
        public Item Clone()
        {
            return new Item(id, amount);
        }

        /// <summary>
        /// Display item id and ammount in a string.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return string.Format("[Id: {0}, Ammount: {1}]", id, amount);
        }
        #endregion Methods
    }
}
